<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span class="hs-cpp">
#ifdef __GLASGOW_HASKELL__
</span><span class="hs-pragma">{-# LANGUAGE MagicHash #-}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK hide #-}</span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-comment">-- | Really unsafe pointer equality</span><span>
</span><span id="line-9"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Utils.Containers.Internal.PtrEquality</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#ptrEq"><span class="hs-identifier">ptrEq</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#hetPtrEq"><span class="hs-identifier">hetPtrEq</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#ifdef __GLASGOW_HASKELL__
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">reallyUnsafePtrEquality#</span></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Unsafe.Coerce.html#"><span class="hs-identifier">Unsafe.Coerce</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Unsafe.Coerce.html#unsafeCoerce"><span class="hs-identifier">unsafeCoerce</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &lt; 707
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.Exts</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">(</span><span class="hs-operator">==#</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">isTrue#</span></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- | Checks if two pointers are equal. Yes means yes;</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- no means maybe. The values should be forced to at least</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- WHNF before comparison to get moderately reliable results.</span><span>
</span><span id="line-24"></span><span id="local-6989586621679158426"><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#ptrEq"><span class="hs-identifier hs-type">ptrEq</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679158426"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158426"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-comment">-- | Checks if two pointers are equal, without requiring</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- them to have the same type. The values should be forced</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- to at least WHNF before comparison to get moderately</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- reliable results.</span><span>
</span><span id="line-30"></span><span id="local-6989586621679158422"><span id="local-6989586621679158423"><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#hetPtrEq"><span class="hs-identifier hs-type">hetPtrEq</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679158423"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158422"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span class="hs-cpp">

#ifdef __GLASGOW_HASKELL__
</span><span class="hs-cpp">#if __GLASGOW_HASKELL__ &lt; 707
</span><span class="hs-identifier">ptrEq</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">reallyUnsafePtrEquality#</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-operator">==#</span><span> </span><span class="hs-number">1#</span><span>
</span><span id="line-35"></span><span class="hs-identifier">hetPtrEq</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafeCoerce</span><span> </span><span class="hs-identifier">reallyUnsafePtrEquality#</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-operator">==#</span><span> </span><span class="hs-number">1#</span><span class="hs-cpp">
#else
</span><span id="ptrEq"><span class="annot"><span class="annottext">ptrEq :: forall a. a -&gt; a -&gt; Bool
</span><a href="Utils.Containers.Internal.PtrEquality.html#ptrEq"><span class="hs-identifier hs-var hs-var">ptrEq</span></a></span></span><span> </span><span id="local-6989586621679158413"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679158413"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679158412"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679158412"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><span class="hs-identifier hs-var">isTrue#</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; a -&gt; Int#
forall a. a -&gt; a -&gt; Int#
</span><span class="hs-identifier hs-var">reallyUnsafePtrEquality#</span></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679158413"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679158412"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span id="hetPtrEq"><span class="annot"><span class="annottext">hetPtrEq :: forall a b. a -&gt; b -&gt; Bool
</span><a href="Utils.Containers.Internal.PtrEquality.html#hetPtrEq"><span class="hs-identifier hs-var hs-var">hetPtrEq</span></a></span></span><span> </span><span id="local-6989586621679158411"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679158411"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679158410"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679158410"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><span class="hs-identifier hs-var">isTrue#</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Any -&gt; Any -&gt; Int#) -&gt; a -&gt; b -&gt; Int#
forall a b. a -&gt; b
</span><a href="../../base/src/Unsafe.Coerce.html#unsafeCoerce"><span class="hs-identifier hs-var">unsafeCoerce</span></a></span><span> </span><span class="annot"><span class="annottext">Any -&gt; Any -&gt; Int#
forall a. a -&gt; a -&gt; Int#
</span><span class="hs-identifier hs-var">reallyUnsafePtrEquality#</span></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679158411"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679158410"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#else
</span><span class="hs-comment">-- Not GHC</span><span>
</span><span id="line-43"></span><span class="hs-identifier">ptrEq</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">False</span><span>
</span><span id="line-44"></span><span class="hs-identifier">hetPtrEq</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">False</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-47"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#ptrEq"><span class="hs-pragma hs-type">ptrEq</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-48"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#hetPtrEq"><span class="hs-pragma hs-type">hetPtrEq</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-keyword">infix</span><span> </span><span class="hs-number">4</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#ptrEq"><span class="hs-operator hs-type">`ptrEq`</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">infix</span><span> </span><span class="hs-number">4</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.PtrEquality.html#hetPtrEq"><span class="hs-operator hs-type">`hetPtrEq`</span></a></span><span>
</span><span id="line-52"></span></pre></body></html>